Next | Prev | Up | Top | Contents | Index
The GLXFBConfig Construct
A GLXFBConfig describes the format, type, and size of the color buffer and ancillary buffers for a GLX drawable. When the GLX drawable is a window, then the GLXFBConfig that describes it has an associated X visual; for a GLXPixmap or GLXPbuffer there may or may not be an X visual associated with the GLXFBConfig.
Choosing a GLXFBConfig Construct
Use glXChooseFBConfigSGIX() to get GLXFBConfig constructs that match a list of attributes or to get the list of GLXFBConfig constructs (GLXFBConfigs) that are available on the specified screen.
GLXFBConfig *glXChooseFBConfigSGIX(Display *dpy, int screen,
const int *attrib_list, int *nitems)
If attrib_list is NULL, glXChooseFBConfigSGIX() returns an array of GLXFBConfigs that are available on the specified screen; otherwise this call returns an array of GLXFBConfigs that match the specified attributes. Table 9-2 shows only attributes specified by this extension; additional attributes are listed on the glXChooseVisual() reference page.
Attributes Introduced by GLXFBConfig
Attribute | Type | Description |
---|
GLX_DRAWABLE_TYPE_SGIX | bitmask | Mask indicating which GLX drawables are supported. Valid bits are GLX_WINDOW_BIT_SGIX and GLX_PIXMAP_BIT_SGIX. |
GLX_RENDER_TYPE_SGIX | bitmask | Mask indicating which OpenGL rendering modes are supported. Valid bits are GLX_RGBA_BIT_SGIX and GLX_COLOR_INDEX_BIT_SGIX. |
GLX_X_RENDERABLE_SGIX | Boolean | True if X can render to drawable. |
GLX_FBCONFIG_ID_SGIX | XID | XID of GLXFBConfig. |
The attributes are matched in an attribute-specific manner. Some attributes, such as GLX_LEVEL, must match the specified value exactly; others, such as GLX_RED_SIZE, must meet or exceed the specified minimum values. The sorting criteria are defined as follows:
- smaller
- GLXFBConfigs with an attribute value that meets or exceeds the specified value are matched. Precedence is given to smaller values (when a value is not explicitly requested, the default is implied).
- larger
- When the value is requested explicitly, only GLXFBConfigs with a corresponding attribute value that meets or exceeds the specified value are matched. Precedence is given to larger values. When the value is not requested, explicitly behaves exactly like the "smaller" criterion.
- exact
- Only GLXFBConfigs whose corresponding attribute value exactly matches the requested value are considered.
- mask
- For a config to be considered, all the bits that are set in the requested value must be set in the corresponding attribute. (Additional bits might be set in the attribute.)
Note also that "don't care" means that the default behavior is to have no preference when searching for a matching GLXFBConfig.
Table 9-3 illustrates how each attribute is matched.
GLXFBConfig Attribute Defaults and Sorting Criteria
Attribute | Default | Sorting Criteria |
---|
GLX_BUFFER_SIZE | 0 | smaller |
GLX_LEVEL | 0 | smaller |
GLX_DOUBLEBUFFER | don't care | smaller |
GLX_STEREO | False | exact |
GLX_AUX_BUFFERS | 0 | smaller |
GLX_RED_SIZE | 0 | larger |
GLX_GREEN_SIZE | 0 | larger |
GLX_BLUE_SIZE | 0 | larger |
GLX_ALPHA_SIZE | 0 | larger |
GLX_DEPTH_SIZE | 0 | larger |
GLX_STENCIL_SIZE | 0 | larger |
GLX_ACCUM_RED_SIZE | 0 | larger |
GLX_ACCUM_GREEN_SIZE | 0 | larger |
GLX_ACCUM_BLUE_SIZE | 0 | larger |
GLX_ACCUM_ALPHA_SIZE | 0 | larger |
GLX_SAMPLE_BUFFERS_SGIS | 0 if GLX_SAMPLES_ SGIS = 0, 1 otherwise | smaller |
GLX_SAMPLES_SGIS | 0 | smaller |
GLX_X_VISUAL_TYPE_EXT | don't care | exact |
GLX_TRANSPARENT_TYPE_EXT | GLX_NONE_EXT | exact |
GLX_TRANSPARENT_INDEX_VALUE_EXT | don't care | exact |
GLX_TRANSPARENT_RED_VALUE_EXT | don't care | exact |
GLX_TRANSPARENT_GREEN_VALUE_EXT | don't care | exact |
GLX_TRANSPARENT_BLUE_VALUE_EXT | don't care | exact |
GLX_TRANSPARENT_ALPHA_VALUE_EXT | don't care | exact |
GLX_VISUAL_CAVEAT_EXT | GLX_NONE_EXT | exact, if specified, otherwise minimum. |
GLX_DRAWABLE_TYPE_SGIX | GLX_WINDOW_BIT_ SGIX | mask |
GLX_RENDER_TYPE_SGIX | GLX_RGBA_BIT_SGIX | mask |
GLX_X_RENDERABLE_SGIX | don't care | exact |
GLX_FBCONFIG_ID_SGIX | don't care | exact |
There are several uses for the glXChooseFBConfigSGIX() function:
- Retrieve all GLXFBConfigs on the screen (attrib_list is NULL).
- Retrieve a GLXFBConfig with a given ID specified with GLX_FBCONFIG_ID_SGIX.
- Retrieve the GLXFBConfig that's the best match for a given list of visual attributes.
- Retrieve first a list of GLXFBConfigs that match some criteria, for example, each GLXFBConfig available on the screen or all double-buffered visuals available on the screen. Then call glXGetFBConfigAttribSGIX() to find their attributes and choose the one that best fits your needs.
Once the GLXFBConfig is obtained, you can use it to create a GLX pixmap, window, or pbuffer (see "The Pixel Buffer Extension"). In the case of a window, you must first get the associated X visual by calling glXGetVisualFromFBConfigSGIX().
Below is a description of what happens when you call glXChooseFBConfigSGIX():
- If no conforming GLXFBConfig exists, or if an error occurs (that is, an undefined GLX attribute is encountered in attrib_list, screen is invalid, or dpy does not support the GLX extension) then NULL is returned.
- If attrib_list is not NULL and more than one GLXFBConfig is found, then an ordered list is returned with the GLXFBConfigs that form the "best" match at the beginning of the list. ("How a GLXFBConfig Is Selected" describes the selection process.) Use XFree() to free the memory returned by glXChooseFBConfigSGIX().
- If GLX_RENDER_TYPE_SGIX is in attrib_list, the value that follows is a mask indicating which types of drawables will be created with it. For example, if GLX_RGBA_BIT_SGIX | GLX_COLOR_INDEX_BIT_SGIX is specified as the mask, then glXChooseFBConfigSGIX() searches for GLXFBConfigs that can be used to create drawables that work with both RGBA and color index rendering contexts. The default value for GLX_RENDER_TYPE_SGIX is GLX_RGBA_BIT_SGIX.
The attribute GLX_DRAWABLE_TYPE_SGIX has as its value a mask indicating which drawables to consider. Use it to choose GLXFBConfigs that can be used to create and render to a particular GLXDrawable. For example, if GLX_WINDOW_BIT_SGIX | GLX_PIXMAP_BIT_SGIX is specified as the mask for GLX_DRAWABLE_TYPE_SGIX then glXChooseFBConfigSGIX() searches for GLXFBConfigs that support both windows and GLX pixmaps. The default value for GLX_DRAWABLE_TYPE_SGIX is GLX_WINDOW_BIT_SGIX.
If a GLXFBConfig supports windows it has an associated X visual. Use the GLX_X_VISUAL_TYPE_EXT attribute to request a particular type of X visual.
Note that RGBA rendering may be supported for any of the six visual types, but color index rendering can be supported only for PseudoColor, StaticColor, GrayScale, and StaticGray visuals (that is, single-channel visuals). The GLX_X_VISUAL_TYPE_EXT attribute is ignored if GLX_DRAWABLE_TYPE_SGIX is specified in attrib_list and the mask that follows does not have GLX_WINDOW_BIT_SGIX set.
GLX_X_RENDERABLE_SGIX is a Boolean indicating whether X can be used to render into a drawable created with the GLXFBConfig. This attribute is always True if the GLXFBConfig supports windows and/or GLX pixmaps.
Retrieving GLXFBConfig Attribute Values
To get the value of a GLX attribute for a GLXFBConfig, call
int glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfig config,
int attribute, int *value)
If glXGetFBConfigAttribSGIX() succeeds, it returns Success, and the value for the specified attribute is returned in value; otherwise it returns an error.
Note: A GLXFBConfig has an associated X visual if and only if the GLX_DRAWABLE_TYPE_SGIX value has the GLX_WINDOW_BIT_SGIX bit set.
To retrieve the associated visual, call:
XVisualInfo *glXGetVisualFromFBConfigSGIX(Display *dpy,
GLXFBConfig config)
If config is a valid GLXFBConfig and it has an associated X visual, then information describing that visual is returned; otherwise NULL is returned. Use XFree() to free the returned data.
It is also possible to get a GLXFBConfig, given visual information:
GLXFBConfig glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
If the visual is valid and supports OpenGL rendering (that is, if the GLX visual attribute GLX_USE_GL is True) then the associated GLXFBConfig is returned; otherwise NULL is returned.
To create a GLX rendering context or a GLX pixmap using a GLXFBConfig, call glXCreateContextWithConfigSGIX() or glXCreateGLXPixmapWithConfigSGIX(). The functions are similar to glXCreateContext() and glXCreateGLXPixmap(). See the reference page for detailed information.
Next | Prev | Up | Top | Contents | Index